a, b, c, d = map(int, input().split())
first = a * 60 + b
second = c * 60 + d
if first < second:
    duration = second - first
else:
    duration = second - first + 24 * 60
hours = duration // 60
minutes = duration % 60
print("O JOGO DUROU %d HORA(S) E %d MINUTO(S)" % (hours, minutes))
